import { Message } from 'element-ui'
function arrayIndexOf (val, array = []) {
  console.log(val.type, '-----------------')
  console.log(val, 'arrayIndexOf', val.authName)
  for (var i = 0; i < array.length; i++) {
    console.log(array[i].authName, 'arrayIndexOf', val.authName)
    if (array[i].authName === val.authName) {
      return i
    }
  }
  return -1
}

function arrayRemove (val, array = []) {
  var index = arrayIndexOf(val)
  console.log(index, 3333333, val)
  if (index > -1) {
    array.splice(index, 1)
  }
  return array
}

function RegularEmail (emailAddres) {
  let ZZemail = /^\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/
  if (ZZemail.test(emailAddres)) {
    return true
  } else {
    return false
  }
}

function RegularLink (linkAddres) {
  console.log(linkAddres, '__________')
  var Expression = /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/
  var objExp = new RegExp(Expression)
  if (objExp.test(linkAddres)) {
    console.log('ok')
    return true
  } else {
    console.log('no')
    return false
  }
}

function RegularAddrees (walletAddres) {
  let wallet = /^(0x)?[0-9a-fA-F]{40}$/
  if (wallet.test(walletAddres)) {
    return true
  } else {
    return false
  }
}

function MessagePormpt (langType, langObj) {
  if (langType === 'zh-cn') {
    Message(langObj.zh_cn)
    return
  }
  if (langType === 'en') {
    Message(langObj.en)
    return
  }
  if (langType === 'zh-tw') {
    Message(langObj.zh_tw)
    return
  }
  if (langType === 'ru') {
    Message(langObj.ru)
  }
}
export {arrayRemove, RegularEmail, RegularLink, RegularAddrees, MessagePormpt}
